package com.jms.controller.fre;

import java.io.File;
import java.util.HashMap;
import java.util.Map;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.context.ServletContextAware;

import com.jms.pageModel.cms.News;
import com.jms.utils.CreateHTML;

@Controller
@RequestMapping("/hello")
public class HelloController implements ServletContextAware{
	private ServletContext servletContext;
	@RequestMapping("/index")
	public void getFirstPage(HttpServletRequest request) {

		try {
			Map root = new HashMap();
			News news = new News();
			news.setTitle("这是一个标题");
			root.put("news", news);
			CreateHTML chtml = new CreateHTML();
			chtml.geneHtmlFile("index.ftl", root, servletContext
					.getRealPath("/www"), "index.html", request
					.getServletContext().getRealPath("/WEB-INF/templates"));
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
		}

	}
	public static void main(String[] args) {
		HelloController hc = new HelloController();
		System.out.println(hc.getClass().getResourceAsStream(""));
		System.out.println(HelloController.class.getResource("/"));
	}
	@Override
	public void setServletContext(ServletContext arg0) {
		this.servletContext = servletContext;
		
	}
}
